#pragma once
#include "ridefactory.h"
#include "SgObject.h"
#include "SgColor.h"
#include "SgComposite.h"
#include "SgRegularPolygon.h"
#include "SgPolygon.h"
#include "SgRegularCylinder.h"
#include "SgRotateAroundPoint.h"
#include "SgTranslate.h"
#include "SgTransform.h"
#include "SgMesh.h"
#include "graphics/GrVector.h"

class CMerryRoundFactory :
	public CRideFactory
{
public:
	CMerryRoundFactory(void);
	virtual ~CMerryRoundFactory(void);
	void Create(CSgComposite* root);
	inline void Normalize(GLdouble *v)
	{
		GLdouble len = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
		v[0] /= len;
		v[1] /= len;
		v[2] /= len;
	}

private:
	CSgComposite* m_root;
public:
	void CreateBase(CSgComposite* parent);
	void CreateRoof(CSgComposite* parent);
	void CreateHorse(CSgComposite* parent);
	void CreateCorn(CSgComposite* parent);
	void CreateHorse2(CSgComposite* parent);
private:
	double m_spinangle;
	CSgMesh *horse;
	CSgPtr<CSgTexture> fish_tex;
	UINT_PTR m_spinTimer;
	CSgPtr<CSgTexture> corntex;
	CSgPtr<CSgTexture> pillar_tex;
	CSgPtr<CSgTexture> roof_tex1;
	CSgPtr<CSgTexture> roof_tex2;
	CSgPtr<CSgTexture> horse_tex1;
	CSgPtr<CSgTexture> floor_tex1;
public:
	void CreateRod(CSgComposite* parent);
	void CreateFence(CSgComposite * parent);
};
